package com.bjpowernode.app.controller;
import com.bjpowernode.app.service.MyServer;
import com.bjpowernode.app.service.MyServerP3;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
public class IndexController {
    @Autowired
    MyServer myServer;
    @Autowired
    MyServerP3 myServerP3;


    @RequestMapping("/index")
    public String index() {
        String result = myServer.getA();
        System.out.println("index:" + result);
        return result;
    }

    @RequestMapping("/index2")
    public String index2() {
        return myServerP3.getB();
    }


    @RequestMapping("/index3")
    public String index3() {
        String result = myServer.getA() + myServerP3.getB();
        return result;
    }


    @RequestMapping("/index4")
    public String index4(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException {
        String result = myServerP3.getB();
        System.out.println("index4:" + result);
        httpServletResponse.sendRedirect("/index");
        return "redirect:index";
    }
}